cmake_minimum_required(VERSION 3.5)

project(SeatDetectionDaheng VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(D:/Daheng/inc)
link_directories(D:/Daheng/lib/x64)
include_directories(D:/auboi5/inc)
link_directories(D:/auboi5/lib)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS XML)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Sql)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGL)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGLWidgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS SerialPort)

set(PROJECT_SOURCES
        main.cpp
        mainwindow.cpp
        mainwindow.h
        mainwindow.ui
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
    qt_add_executable(SeatDetectionDaheng
        MANUAL_FINALIZATION
        ${PROJECT_SOURCES}
        seatdetectionparameter.h seatdetectionparameter.cpp
        controlcommand.h controlcommand.cpp
        detectionresult.h detectionresult.cpp
        defectinfo.h defectinfo.cpp
        TCPRecognizeClient.h
        TCPRecognizeClient.cpp
        seatparameterdialog.h seatparameterdialog.cpp seatparameterdialog.ui
        savelog.h
        savelog.cpp
        newcameradialog.h newcameradialog.cpp newcameradialog.ui
        customgraphicsview.h
        customgraphicsview.cpp
        customimageitem.h customimageitem.cpp
        viewwidget.ui
        viewwidget.h
        viewwidget.cpp
        detectiondialog.h detectiondialog.cpp detectiondialog.ui
        res.qrc
        imagedetaildialog.h imagedetaildialog.cpp imagedetaildialog.ui
        defect.h defect.cpp
        detection.h detection.cpp
        seat.h seat.cpp
        detectionresultset.h detectionresultset.cpp
        sqlitedatabasedao.h sqlitedatabasedao.cpp
        defectdao.h defectdao.cpp
        detectiondao.h detectiondao.cpp
        seatdao.h seatdao.cpp
        plccontrolcmd.h plccontrolcmd.cpp
        seatmatcher.h seatmatcher.cpp
        LogManager.h
        LogManager.cpp
        simpleQtLogger.h
        simpleQtLogger.cpp
        myopenglwidget.h tiny_obj_loader.h
        myopenglwidget.cpp tiny_obj_loader.cc
        seatshowinfodialog.h seatshowinfodialog.cpp seatshowinfodialog.ui
        GxBitmap.cpp
        GXBitmap.h
        dahengcamera.h dahengcamera.cpp
        camera.h camera.cpp
        scancamerathread.h scancamerathread.cpp
        description/delay.cpp description/description.cpp
        description/device.cpp description/ethernet.cpp
        description/jakarobot.cpp
        description/movejoint.cpp
        description/objectfactory.cpp description/operation.cpp
        description/recognize.cpp description/rs232.cpp
        description/snap.cpp description/step.cpp
        description/wordopcontrolled.cpp
        description/delay.h description/description.h
        description/device.h description/ethernet.h
        description/jakarobot.h
        description/ledcontroller.h
        description/movejoint.h description/objectfactory.h
        description/operation.h description/recognize.h
        description/rs232.h description/snap.h
        description/step.h description/wordopcontrolled.h
        description/TCPSubClient.h description/TCPSubClient.cpp
        TCPPLCClient.h
        TCPPLCClient.cpp
        description/virtualdevice.h
        description/virtualdevice.cpp
        waitfortheloading.h waitfortheloading.cpp waitfortheloading.ui
        waitdialog.h waitdialog.cpp
        description/auborobot.h description/auborobot.cpp
        selfcheckingthread.h selfcheckingthread.cpp
        historyinformation.h


    )
# Define target properties for Android with Qt 6 as:
#    set_property(TARGET SeatDetectionDaheng APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
#                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
    if(ANDROID)
        add_library(SeatDetectionDaheng SHARED
            ${PROJECT_SOURCES}
        )
# Define properties for Android with Qt 5 after find_package() calls as:
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
    else()
        add_executable(SeatDetectionDaheng
            ${PROJECT_SOURCES}
        )
    endif()
endif()

target_link_libraries(SeatDetectionDaheng PRIVATE libserviceinterface)
target_link_libraries(SeatDetectionDaheng PRIVATE Qt${QT_VERSION_MAJOR}::Widgets jakaAPI GxIAPI DxImageProc)
target_link_libraries(SeatDetectionDaheng PRIVATE Qt${QT_VERSION_MAJOR}::Xml)
target_link_libraries(SeatDetectionDaheng PRIVATE Qt${QT_VERSION_MAJOR}::Network)
target_link_libraries(SeatDetectionDaheng PRIVATE Qt${QT_VERSION_MAJOR}::Sql)
target_link_libraries(SeatDetectionDaheng PRIVATE Qt${QT_VERSION_MAJOR}::OpenGL)
target_link_libraries(SeatDetectionDaheng PRIVATE Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
target_link_libraries(SeatDetectionDaheng PRIVATE Qt${QT_VERSION_MAJOR}::SerialPort)


# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
  set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.SeatDetectionDaheng)
endif()
set_target_properties(SeatDetectionDaheng PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})

include(GNUInstallDirs)
install(TARGETS SeatDetectionDaheng
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
    qt_finalize_executable(SeatDetectionDaheng)
endif()
